package com.my.function;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.Consumer;
import java.util.function.Predicate;

/**
 * Created by ZhongGang
 * at 2018/8/29 16:13
 */
public class Function {
    private static final Logger LOGGER = LoggerFactory.getLogger(Function.class);

    public static void main(String[] args) throws Exception {
        Action<String> action = System.out::println;
        action.execute("Hello world");

        Consumer consumer = Function::talk;
        consumer.andThen(consumer).accept("I am Alex");

        Predicate<String> predicate = (t) -> t != null;
        consumer.accept(predicate.test(""));
    }

    private static <T> void talk(T t) {
        System.out.println(t);
    }

    @FunctionalInterface
    public interface Action<T> {

        void execute(T t);
    }

}
